import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] array = new int[5]; // 定义大小为5的数组

        while (true) {
            String command = scanner.next();
            if ("arr".equals(command)) {
                try {
                    int index = scanner.nextInt();
                    // 尝试访问数组中的元素，可能会抛出ArrayIndexOutOfBoundsException
                    System.out.println(array[index]);
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.out.println(e);
                }
            } else if ("null".equals(command)) {
                // 产生NullPointerException
                String s = null;
                try {
                    s.length();
                } catch (NullPointerException e) {
                    System.out.println(e);
                }
            } else if ("cast".equals(command)) {
                // 产生ClassCastException
                try {
                    Object obj = "hello";
                    Integer num = (Integer) obj;
                } catch (ClassCastException e) {
                    System.out.println(e);
                }
            } else if ("num".equals(command)) {
                try {
                    String input = scanner.next();
                    // 尝试将输入转换为整数，可能会抛出NumberFormatException
                    Integer.parseInt(input);
                } catch (NumberFormatException e) {
                    System.out.println(e);
                }
            } else if ("other".equals(command)) {
                // 结束程序
                break;
            }
        }
        scanner.close();
    }
}